package com.lagou.springbootjpathymeleaf;

import com.lagou.springbootjpathymeleaf.example.config.InitListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

@SpringBootApplication
public class SpringBootJpaThymeleafApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringBootJpaThymeleafApplication.class, args);
	}

	@Bean
	public ServletListenerRegistrationBean servletListenerRegistrationBean() {
		ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
		servletListenerRegistrationBean.setListener(new InitListener());
		return servletListenerRegistrationBean;
	}

//	@Bean
//	public DataSource dataSource() {
//		MyDataSource dataSource = new MyDataSource();
//		dataSource.setUrl("mysql://127.0.0.1/lagoutest?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false");
//		dataSource.setUsername("root");
//		dataSource.setPassword("xp0210");
//		dataSource.setDefaultReadOnly(false);
//		return  dataSource;
//	}

}
